<template>
  <div class="first">
    <div class="first-swipe">
      <van-swipe :autoplay="3000">
        <van-swipe-item v-for="(item, index) in img" :key="index">
          <img :src="'http://47.102.145.189:8009'+item.imgSrc" alt />
        </van-swipe-item>
      </van-swipe>
      <div class="search">
        <span>
          <p @click="city">
            {{arealist.label}}
            <van-icon name="arrow-down" />
          </p>
          <van-icon name="search" />
          <input type="text" placeholder="请输入小区或地址" />
        </span>
        <div class="first-map" @click="maps()">
          <i class="el-icon-map-location"></i>
          <!-- <van-icon name="user-circle-o" color="rgb(41, 175, 41)" /> -->
        </div>
      </div>
    </div>
    <div class="first-header">
      <router-link to="/home/room">
        <van-icon name="home-o" color="rgb(129, 235, 129)" />整租
      </router-link>
      <router-link to="/home/room">
        <van-icon name="friends-o" color="rgb(129, 235, 129)" />合租
      </router-link>
      <router-link to="/home/first/map">
        <van-icon name="location-o" color="rgb(129, 235, 129)" />地图找房
      </router-link>
      <router-link to="/home/first/lend">
        <van-icon name="wap-home-o" color="rgb(129, 235, 129)" />去出租 
      </router-link>
    </div>
    <div class="first-main">
      <div class="group">
        <div class="group-header">
          <span>租房小组</span>
          <span></span>
          <span class="many">更多</span>
        </div>
        <div class="group-main">
          <div class="group-squad" v-for="(item,ind) in squad" :key="ind">
            <dl>
              <dd>
                <p>{{item.title}}</p>
                <p class="small">{{item.desc}}</p>
              </dd>
              <dt>
                <img :src="'http://47.102.145.189:8009'+item.imgSrc" alt />
              </dt>
            </dl>
          </div>
        </div>
      </div>
      <div class="message-content">
        <div class="message-header">
          <span>最新资讯</span>
        </div>
        <div class="message-main">
          <div v-for="(item,ind) in message" :key="ind">
            <dl>
              <dt>
                <img :src="'http://47.102.145.189:8009'+item.imgSrc" alt />
              </dt>
              <dd>
                <p>{{item.title}}</p>
                <p class="datas">
                  <span>{{item.from}}</span>
                  <span>{{item.date}}</span>
                </p>
              </dd>
            </dl>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import {mapState} from 'vuex'
export default {
  data() {
    return {
      img: [],
      squad: [],
      message: []
    };
  },
  computed:{
    ...mapState(['arealist'])
  },
  methods: {
    async getAddress() {
      let res = await this.$http.get("/home/swiper");
      console.log(res);
      this.img = res.data.body;
    },
    async getAdd() {
      let res = await this.$http.get("/home/groups");
      console.log(res);
      this.squad = res.data.body;
    },
    async news() {
      let res = await this.$http.get("/home/news");
      console.log(res);
      this.message = res.data.body;
    },
    city() {
      this.$router.push("/citylist");
    },
    maps() {
      this.$router.push("/home/first/map");
    }
  },
  created() {
    this.getAddress();
    this.getAdd();
    this.news();
  }
};
</script>

<style>
.van-swipe {
  height: 200px;
  /* background: #999; */
}
.van-swipe img {
  width: 100%;
  height: 200px;
  position: relative;
}
.van-swipe__indicators i {
  background: #999999;
}
.search {
  width: 100%;
  height: 50px;
  display: flex;
  align-items: center;
  padding: 0 15px;
  font-size: 15px;
  position: absolute;
  left: 0;
  top: 15px;
}
.search p {
  padding-right: 10px;
  border-right: 1px solid #cccccc;
}
.search span {
  width: 100%;
  height: 35px;
  background: #ffffff;
  display: flex;
  align-items: center;
  padding-left: 10px;
  border-radius: 5px;
}
.search span i {
  padding-left: 10px;
}
.search span input {
  border: none;
  text-indent: 10px;
  font-size: 10px;
}
.search > i {
  font-size: 30px;
  padding-left: 10px;
  color: #ffffff;
}
.first-header {
  width: 100%;
  height: 80px;
  background: #ffffff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
}
.first-header a {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  color: #000;
}
.first-header i {
  font-size: 28px;
  width: 50px;
  height: 50px;
  background: rgb(230, 250, 230);
  line-height: 50px;
  text-align: center;
  border-radius: 50px;
  padding-bottom: 10px;
}
.first-main {
  width: 100%;
  height: 100%;
}
.first-main .group {
  width: 100%;
  height: 200px;
}
.group-header {
  width: 100%;
  height: 50px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
}
.group-header span {
  font-size: 15px;
  font-weight: bold;
}
.group-header .many {
  font-weight: normal;
  color: #868585;
}
.group-main {
  width: 100%;
  height: 200px;
}
.group-main {
  width: 100%;
  height: 180px;
  display: flex;
  flex-wrap: wrap;
  text-align: center;
  justify-content: space-between;
  padding: 0 10px;
}
.group-squad {
  width: 48%;
  height: 80px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #ffffff;
}
.group-squad dl {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 10px;
}
.group-squad dl dd {
  font-size: 13px;
}
.group-squad dl dt img {
  width: 55px;
  height: 55px;
}
.group-squad dl dd .small {
  font-size: 12.5px;
  color: #a5a4a4;
}
.message-content {
  width: 100%;
  height: 412px;
  background: #ffffff;
  margin-top: 30px;
}
.message-header {
  width: 100%;
  height: 50px;
  display: flex;
  align-items: center;
  padding-left: 20px;
}
.message-header span {
  font-size: 15px;
  font-weight: bold;
}
.message-main {
  width: 100%;
  height: 395px;
  padding: 5px 20px;
}
.message-main dl {
  width: 100%;
  height: 120px;
  display: flex;
  justify-content: space-between;
  padding: 15px 10px 15px 0;
  border-bottom: 1px solid #cccccc;
}
.message-main dl dt img {
  width: 120px;
  height: 90px;
}
.message-main dl dd {
  padding-left: 10px;
  font-size: 14px;
}
.message-main dl dd p {
  font-weight: bold;
  margin-bottom: 30px;
}
.message-main .datas {
  font-size: 14px;
  font-weight: normal;
  display: flex;
  justify-content: space-between;
}
.first-map i {
  display: flex;
  padding: 0 10px;
  font-size: 25px;
  color: #ffffff;
}
</style>